package com.scalar.chiptrack.adaptor.grace;

import Acme.HtmlObserver;

import java.net.URL;

/**
 * Created by IntelliJ IDEA.
 * User: Sudhakar
 * Date: Apr 30, 2007
 * Time: 7:50:44 PM
 */
public class GraceHtmlObserver implements HtmlObserver
{

     private String downloadCsvURL = null;
    private String downloadTextURL = null;

    public String getDownloadCsvURL() {
        return downloadCsvURL;
    }

    public void setDownloadCsvURL(String downloadCsvURL) {
        this.downloadCsvURL = downloadCsvURL;
    }

    public String getDownloadTextURL() {
        return downloadTextURL;
    }

    public void setDownloadTextURL(String downloadTextURL) {
        this.downloadTextURL = downloadTextURL;
    }

    public void gotAHREF( String urlString, URL contextUrl, Object clientData )
    {
        if ( urlString == null ) return;

        if( urlString.indexOf("doDownload") != -1 )
        {
            int startIndex = 0;
            int endIndex = 0;

            startIndex = urlString.indexOf('(');
            endIndex    = urlString.indexOf(')');
            urlString = urlString.substring(startIndex + 2, endIndex-1);
            downloadCsvURL = "/vfab" + urlString;
        }
    }

    public void gotAREAHREF( String urlString, URL contextUrl, Object clientData )
    {
    }

    public void gotBASEHREF( String urlString, URL contextUrl, Object clientData )
    {
    }

    public void gotBODYBACKGROUND( String urlString, URL contextUrl, Object clientData )
    {
        //System.out.println("urlString = "+urlString);
    }

    public void gotFRAMESRC( String urlString, URL contextUrl, Object clientData )
        {

        }

     public void gotIMGSRC( String urlString, URL contextUrl, Object clientData )
    {
    }

    public void gotLINKHREF( String urlString, URL contextUrl, Object clientData )
    {
    }
}
